/**
 * 
 */

package com.wutianyi.taskqueue.dataobject;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;

import com.wutianyi.taskqueue.queue.Task;

/**
 * @author wutianyi
 * 
 */
public class TaskQueueDO implements Task {

	/**
	 * 
	 */
	private static final long	serialVersionUID	= -1983576203224185716L;
	private static Logger		logger				= Logger.getLogger(TaskQueueDO.class);

	private ObjectMapper		mapper				= new ObjectMapper();

	private String				taskId;
	private String				taskName;
	private long				beginDealTime;
	private int					hideTime;
	private volatile int		status;

	public TaskQueueDO() {

	}

	public TaskQueueDO(String taskId) {

	}

	public String getTaskPropsString() {

		return null;
	}

	public void setTaskPropsString(String props) {

	}

	public boolean isOutOfTime(long curTime) {

		if(curTime - beginDealTime >= hideTime) {
			return true;
		}
		return false;
	}

	public String getTaskId() {

		return taskId;
	}

	public void setTaskId(String taskId) {

		this.taskId = taskId;
	}

	public void setTaskName(String taskName) {

		this.taskName = taskName;
	}

	public long getBeginDealTime() {

		return beginDealTime;
	}

	public void setBeginDealTime(long beginDealTime) {

		this.beginDealTime = beginDealTime;
	}

	public int getHideTime() {

		return hideTime;
	}

	public void setHideTime(int hideTime) {

		this.hideTime = hideTime;
	}

	public boolean equals(Object obj) {

		if(null == obj || !(obj instanceof TaskQueueDO)) {
			return false;
		}
		TaskQueueDO task = (TaskQueueDO)obj;
		if(StringUtils.equals(this.getTaskId(), task.getTaskId())) {
			return true;
		}

		return true;
	}

	public int hashCode() {

		return this.getTaskId().hashCode();
	}

	public int getStatus() {

		return status;
	}

	public void setStatus(int status) {

		this.status = status;
	}

}
